package com.itboye.ihomebank.activity.finance;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;

import java.util.Observable;
import java.util.Observer;

/**
 * Created by itboye on 2017/2/17.
 * 投资记录，流水
 */

public class InvestmentGoodsListActivity extends BaseOtherActivity implements Observer{

    private TextView tvLiushui, tvTimeData;
    private boolean isliu = true;//用于判断图片是否旋转
    private String type;//传值给两个按钮，用于区分

    @Override
    protected int layout_id() {
        return R.layout.activityinvetment_tab_view;
    }

    @Override
    protected void onInitController() {

    }

    @Override
    protected void onInit() {


    }

    @Override
    protected void onReadIntent(Bundle bundle) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tvLiushui:
                type = "leift";
                onTextViewDrawables(type);
                Toast toast = Toast.makeText(InvestmentGoodsListActivity.this, "Toast show",
                        Toast.LENGTH_LONG);
                //可以控制toast显示的位置
                toast.setGravity(Gravity.CENTER, 0, 10);
                toast.show();
                break;
            case R.id.tvTimeData:
                type = "right";
                onTextViewDrawables(type);
                break;
        }
    }
    /***
     * 头部TextView图片问题
     *
     * @param type
     */
    public void onTextViewDrawables(String type) {
        if (isliu) {
            isliu = false;
            Drawable nav_up = getResources().getDrawable(R.drawable.paixu);
            nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
            if (type.equals("leift")) {

                tvLiushui.setCompoundDrawables(null, null, nav_up, null);
            } else {
                tvTimeData.setCompoundDrawables(null, null, nav_up, null);
            }

        } else {
            isliu = true;
            Drawable nav_up = getResources().getDrawable(R.drawable.paixu_down);
            nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
            if (type.equals("leift")) {
                tvLiushui.setCompoundDrawables(null, null, nav_up, null);
            } else {
                tvTimeData.setCompoundDrawables(null, null, nav_up, null);
            }
        }
    }

    @Override
    public void update(Observable observable, Object data) {

    }
}
